import { http } from '@/utils/http'
import type { userForm, userInfo } from '@/types/userform'
//发送验证码
export const SendCodeAPI = (account: string) => {
  return http({
    method: 'GET',
    url: '/user/code',
    data: {
      account
    }
  })
}
export const registerAPI = (data: userForm) => {
  return http({
    method: 'POST',
    url: '/user/register',
    data
  })
}
//验证码登录
export const loginCodeAPI = (data: userForm) => {
  return http<userInfo>({
    method: 'POST',
    url: '/user/login/code',
    data
  })
}
//密码登录 
export const loginPasswordAPI = (data: userForm) => {
  return http<userInfo>({
    method: 'POST',
    url: '/user/login/psw',
    data
  })
}
//退出登录
export const loginOutAPI = (token: string) => {
  return http({
    url: `/user/logout?Authorization=${token}`,
    method: 'GET',
  })
}
//修改密码
export const alertPasswordAPI = (data: userForm) => {
  return http({
    url: `/user/modifyUserPSW?account=${data.account}&password=${data.password}&code=${data.code}`,
    method: 'PUT'
  })
}
//忘记密码
export const forgetPasswordAPI = (data: userForm) => {
  return http({
    url: `/user/findUserPSW?account=${data.account}&password=${data.password}&code=${data.code}&rePassword=${data.rePassword}`,
    method: 'PUT'
  })

}